<extend name="template/base_index" />

<block name="area_header">
	<link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
	<link type="text/css" rel="stylesheet" href="__CDN__/select2/4.0.0/css/select2.min.css" />
  <script type="text/javascript" src="__CDN__/select2/4.0.0/js/select2.full.js"></script>
  <script type="text/javascript" src="__CDN__/select2/4.0.0/js/i18n/zh-CN.js"></script>
	<script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/jquery.validate.min.js"></script>
	<script type="text/javascript" src="__CDN__/jquery-validation/1.13.1/localization/messages_zh.min.js"></script>
	<script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
</block>

<block name="area_body">
	{:W('Menus/topbar')}
	<div class="admin-main container-fluid">
		{:W('Menus/left')}
		<div class="admin-main-content">
			{:W('Menus/breadcrumb')}
			<!-- 带验证 form -->
			<form id="AddForm" class="form-horizontal well">
				<fieldset>
					<legend>用户禁言 - 每次覆盖</legend>
					<div class="form-group">
						<label for="uid" class="col-md-2 col-lg-2 control-label">用户</label>
						<div class="col-md-10 col-lg-10">
							<!-- <input type="hidden" name="uid" value="{$userinfo['uid']}"> -->

							 <!-- 过滤\查询按钮 用户选择-->
            	<div class="filter-controls pull-left">
                <form action="" class="addToGroupForm" method="post">
                    <!-- <input type="hidden" name="fid" value="{$fid}" /> -->
                    <!--<input  id="user_select2"  type="text" style="width:220px;padding: 10px 15px;" name="uid" class="form-control" />-->

                    <select style="width:220px;padding: 10px 15px;font-size: 15px;line-height: 1.42857143;" id="user_select2" name="uid" class="form-control">
                        <option value="{$userinfo['uid']}">[id:{$userinfo['uid']}] {$userinfo['nickname']}</option>
                    </select>
                    <!-- <a id="addtogroup" target-form="addToGroupForm" class="ajax-post btn btn-sm btn-primary" href="{:U('Admin/BbsForum/addAdmin')}"></a> -->
                </form>
            	</div>
						</div>
					</div>
					<div class="form-group">
						<label for="time" class="col-md-2 col-lg-2 control-label">结束时间</label>
						<div class="col-md-10 col-lg-10">
							<input type="text" class="required form-control input-short" name="time" id="time" value="{:date('Y-m-d H:i:s')}">
							<div class="help-block">(结束时间)</div>
						</div>
					</div>
					<div class="form-group">
						<label for="btns" class="col-md-2 col-lg-2 control-label">&nbsp;</label>
						<div class="col-lg-10 col-md-10">
							<a target-form="well" class="ajax-post btn btn-primary" href="{:U('Admin/'.CONTROLLER_NAME.'/ban',array('id'=>I('id')))}" autofocus="autofocus"><i class="fa fa-save"></i> {:L('BTN_SAVE')}</a>
							<a class="btn btn-default" href="{:U('Admin/'.CONTROLLER_NAME.'/ban')}"><i class="fa fa-times-circle"></i> {:L('BTN_CANCEL')}</a>
						</div>
					</div>
				</fieldset>
			</form>
			<!-- form -->
		</div>
		<!-- END admin-main-content -->
	</div>
	<!-- END admin-main-->
</block>

<block name="area_footer">
	<script type="text/javascript">
		$('#time').datetimepicker({
			lang: 'ch',
			format:'Y-m-d H:i:s',
			// timepicker:false,
		});
		   $(function(){
            // $("#groups").change(function(){
            //     $(".groupForm").submit();
            // });
            $select2 = $("#user_select2").select2({
                placeholder: "输入用户uid或昵称查询"
                ,
                language: "zh-CN",
                ajax: {
                    url: "{:U('Admin/Member/select')}",
                    dataType: 'json',
                    delay: 250,
                    data: function (params) {
                        var queryParameters = {
                            q: params.term
                        }
                        return queryParameters;
                    },
                    processResults: function (data, page) {
                        if(!data.info){
                            data.info = new Array();
                            data.info['nodata']="无相关数据";
                        }
                        // parse the results into the format expected by Select2.
                        // since we are using custom formatting functions we do not need to
                        // alter the remote JSON data
                        return {
                            results: data.info
                        };
                    },
                    cache: true
                },
                // maximumSelectionLength: 1,
                minimumInputLength: 0,
                templateSelection: function (repo) {
                    return repo.nickname || repo.text;
                },
                templateResult: function (repo) {

                    if (repo.loading) return repo.text;
                    if(repo.nodata) return repo.nodata;
//    				var markup = '<div>'+repo.nickname+'</div>';
                    var markup = '<div><img src="'+repo.head+'" style="width:30px;height:30px;"/>[id:'+repo.id+'] '+repo.nickname+'</div>';
                    return $(markup);
                },
            });
        })
	</script>
</block>